<!DOCTYPE html>
<html lang="en">
<head>
    <title>上传图片</title>
    <meta http-equiv="Content-Type" content="multipart/form-data; charset=utf-8" />
    <script type="text/javascript" src="js/jquery-1.8.3.js"></script>
    <link rel="icon" href="http://39.105.94.75:88/img/favicon.ico">
</head>
<body>

<form action="/uploadimg.do" method="POST" enctype="multipart/form-data">
    文件：<input id="image" type="file" name="image" accept="image/png,image/jpg,image/webp,image/jpeg"/>
    <input name="imgname" type="text" placeholder="请输入图片名称">
    <input name="imginfo" type="text" placeholder="请输入图片信息">
    <input type="submit" value="上传"  onclick="f()"/>
</form>
<script>
function f() {
    var imagSize = document.getElementById("image").files[0].size;
    console.log("图片大小：" + imagSize + "B")
    if(imagSize < 1024 * 1024 * 3){
        console.info("图片大小在3M以内，为：" + imagSize / (1024 * 1024) + "M");
        return true;
    } else
    {
        console.error("图片太大")
        return false;
    }
}

</script>
</body>
</html>
